﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Google.GData.Spreadsheets;
using Google.GData.Client;

namespace GoogleFeeder
{
    public class Cell
    {
        public readonly Worksheet Parent;
        public readonly CellEntry TheCell;

        public Cell(Worksheet parent, CellEntry theCell)
        {
            Parent = parent;
            TheCell = theCell;
        }

        /// <summary>
        /// InputValue: the cell's formula or text value
        /// NumericValue: the cell's calculated value if the cell's value is numeric, empty string if cell's value is not numeric
        /// Value: the cell's displayed value (useful if the cell has a formula)
        /// </summary>
        public string Value
        {
            get
            {
                return TheCell.Cell.Value;
            }
            set
            {
                TheCell.Cell.InputValue = value;
                try
                {
                    TheCell.Update();
                }
                catch
                {
                    // ignore (there's not much to do anyway)
                }
            }
        }
    }
}
